import request from '@/utils/request'

export const commentApi = {
  // 创建评论
  createComment(data) {
    return request({
      url: '/comments',
      method: 'post',
      data
    })
  },

  // 获取评论详情
  getCommentById(commentId) {
    return request({
      url: `/comments/${commentId}`,
      method: 'get'
    })
  },

  // 获取帖子的所有评论
  getCommentsByPost(postId) {
    return request({
      url: `/comments/post/${postId}`,
      method: 'get'
    })
  },

  // 获取用户的所有评论
  getCommentsByAuthor(authorId) {
    return request({
      url: `/comments/author/${authorId}`,
      method: 'get'
    })
  },

  // 更新评论
  updateComment(commentId, data) {
    return request({
      url: `/comments/${commentId}`,
      method: 'put',
      data
    })
  },

  // 删除评论
  deleteComment(commentId) {
    return request({
      url: `/comments/${commentId}`,
      method: 'delete'
    })
  }
} 